<template>
  <div>
    <router-view />
  </div>
</template>

<script>
import storage from "./storage";
export default {
  data() {
    return {
      res: {},
    };
  },
  mounted() {
    if (this.$cookie.get("userId")) {
      this.getUser();
      this.getCartCount();
    }
  },
  methods: {
    getUser() {
      this.axios
        .get("/user")
        .then((res) => {
          this.$store.dispatch("saveUserName", res.username);
        })
        .catch((e) => {});
    },
    getCartCount() {
      this.axios
        .get("/carts/products/sum")
        .then((res=0) => {
          console.log(res,'ee');
          this.$store.dispatch("saveCartCount", res);
        })
        .catch((e) => {});
    },
  },
};
</script>

<style lang="scss">
@import "./assets/scss/reset.scss";
@import "./assets/scss/config.scss";
@import "./assets/scss/button.scss";
</style>